package it.free.i.virtual.machine.knowledgebase.ciuc.basket;

import java.util.Hashtable;
import java.util.List;

import javax.management.Notification;

import org.apache.log4j.Logger;

/**  
 * All the information collected in a unit of time get put here
 * Here lists of jmx notificationS (plural) are stored, they will be tranformed into ciucs: composable information units chains 
 * @author stefano
 */
public class NotificationsListsBasket {

	private static NotificationsListsBasket NOTIFICATIONSLIST_BASKET_INSTANCE = null;
	
	private Hashtable<String, List<Notification>> notifications = new Hashtable<String, List<Notification>>();
	
	private Logger logger = Logger.getLogger(NotificationsListsBasket.class);
	
	/**
	 * Singleton instance accessor
	 * @return the single instance of this object
	 */
	public static final NotificationsListsBasket getInstance(){
		
		if(NOTIFICATIONSLIST_BASKET_INSTANCE == null){
		   synchronized(NotificationsListsBasket.class){
			   if(NOTIFICATIONSLIST_BASKET_INSTANCE == null){
				  NOTIFICATIONSLIST_BASKET_INSTANCE = new NotificationsListsBasket();
			   }
		   }
		}
		return NOTIFICATIONSLIST_BASKET_INSTANCE;
	}
	
	public void add(String key, List<Notification> value){
		this.notifications.put(key, value);
		
		logger.info("Added new notifications list, key: " + key + " size: " + value.size());
		
	}

	/**
	 * @return the notifications
	 */
	public Hashtable<String, List<Notification>> getNotifications() {
		return this.notifications;
	}
	
}
